package com.base.action;

import java.util.List;

import com.common.bean.Menuinfo;
import com.common.util.PagerModel;
import com.common.util.StringToken;

public class MenuinfoManagerAction extends MenuinfoAbstractAction {
	
	private static final long serialVersionUID = -1120651458143787834L;
	private Menuinfo menuinfo;
	
	private long menuid;
	
	private PagerModel pm;
	
	private List<Menuinfo> menulist;

	@Override
	public String execute() throws Exception {
		int offset = 0;
		int pagesize = 10;
		try{
			offset = Integer.parseInt(getRequest().getParameter("pager.offset"));
		}catch(Exception e){
		}
		
		pm = menuService.findMenuinfo(StringToken.ST_MENUID,offset, pagesize);
		return SUCCESS;
	}
	
	public String delMenu() throws Exception {
		menuService.removeMenu(menuid);
		return SUCCESS;
	}
	
	public String findMenu() throws Exception {
		menuinfo = menuService.findMenuinfo(menuid);
		
		int offset = 0;
		int pagesize = 10;
		try{
			offset = Integer.parseInt(getRequest().getParameter("pager.offset"));
		}catch(Exception e){
		}
		pm = menuService.findMenuinfo(menuid, offset, pagesize);
		return SUCCESS;
	}
	
	public String findToUpdateMenu() throws Exception {
		menuinfo = menuService.findMenuinfo(menuid);
		return SUCCESS;
	}
	
	public String goaddMenu() throws Exception {
		menuinfo = new Menuinfo();
		menuinfo.setMenupid(menuid);
		menulist = menuService.findAllMenuinfo();
		return SUCCESS;
	}

	/**
	 * @return the menuinfo
	 */
	public Menuinfo getMenuinfo() {
		return menuinfo;
	}

	/**
	 * @param menuinfo the menuinfo to set
	 */
	public void setMenuinfo(Menuinfo menuinfo) {
		this.menuinfo = menuinfo;
	}

	/**
	 * @return the pm
	 */
	public PagerModel getPm() {
		return pm;
	}

	/**
	 * @param pm the pm to set
	 */
	public void setPm(PagerModel pm) {
		this.pm = pm;
	}

	/**
	 * @return the menuid
	 */
	public long getMenuid() {
		return menuid;
	}

	/**
	 * @param menuid the menuid to set
	 */
	public void setMenuid(long menuid) {
		this.menuid = menuid;
	}

	/**
	 * @return the menulist
	 */
	public List<Menuinfo> getMenulist() {
		return menulist;
	}

	/**
	 * @param menulist the menulist to set
	 */
	public void setMenulist(List<Menuinfo> menulist) {
		this.menulist = menulist;
	}

	
}
